<?php
namespace Admin\Model;
use Think\Model;
/**
* MenuitemModel
*/
class MenuitemModel extends Model
{
	//表单验证
	protected $_validate = array(
		array('name','require','菜单项名称必须填写',1),
	);
	//自动完成
	protected $_auto = array(
		array('path','getPath',3,'callback'),
	);
	public function getPath()
	{
		//获取父菜单项编号
		$pid = I('post.pid');
		//获取父菜单的数据
		$pm = $this->field('id,path')->getById($pid);
		$path = $pid != 0 ? $pm['path'] . '-' . $pm['id'] : 0;
		return $path;
	}
}